/*
 * @Author: xiaosihan
 * @Date: 2024-10-13 04:10:26
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-20 17:56:16
 */

import Api from "./Api";

class AdminApi extends Api {
  constructor() {
    super();
  }

  //发送运营登录的短信
  //运营平台登录
  // 后台是账号密码登录
  //type 0为运营用户，1为普通用户，2为商家用户
  async admin_login(phone: string, password: string, type: number = 0) {
    const result = await this._post("/auth/login", {
      phone,
      password,
      type,
    });
    return result;
  }
  //获取用户列表
  get_user_list(params: {
    data?: {
      phone?: string;
      name?: string;
    };
    isAsc?: boolean;
    sortBy?: string;
    pageNum?: number;
    pageSize?: number;
  }) {
    return this._get("/admin/user/list", { ...params });
  }

  //根据用户ID获取用户信息
  get_user_by_id(id: string) {
    return this._post(`/admin/user/get/${id}`);
  }
  //获取服务类型
  get_service_type_list(params: { pageNum: number; pageSize: number }) {
    return this._post("/admin/serviceType/list", {
      name: "服务类型",
      status: 1,
      ...params,
    });
  }
  //增加服务列表
  add_service_type(params: { iconUrl: string; description: string }) {
    return this._post("/admin/serviceType/add", {
      name: "服务类型",
      status: 1,
      ...params,
    });
  }
  //获取行业领域列表
  get_industry_domain_list(params: { pageNum: number; pageSize: number }) {
    return this._post("/admin/industryDomain/list", {
      data: {
        status: 1,
      },
      ...params,
    });
  }
  //增加行业领域
  add_industry_domain(params: { description: string }) {
    return this._post("/admin/industryDomain/add", {
      name: "行业领域",
      status: 1,
      ...params,
    });
  }
  //获取证书列表
  get_certificate_list(params: { pageNum: number; pageSize: number }) {
    return this._post("/admin/certificate/list", {
      data: {
        status: 1,
      },
      ...params,
    });
  }
  //增加证书
  add_certificate(params: { iconUrl: string }) {
    return this._post("/admin/certificate/add", {
      name: "证书",
      status: 1,
      ...params,
    });
  }
  //通过id获取证书
  get_certificate_by_id(id: string) {
    return this._post(`/admin/certificate/get/${id}`);
  }
  //通过id删除证书
  delete_certificate_by_id(id: string) {
    return this._post(`/admin/certificate/delete/${id}`);
  }
  //修改证书
  update_certificate(params: { id: string; iconUrl: string }) {
    return this._post("/admin/certificate/update", {
      name: "证书",
      status: 1,
      ...params,
    });
  }
  //获取加工类型列表
  get_process_type_list(params: { pageNum: number; pageSize: number }) {
    return this._post("/admin/processType/list", {
      data: {
        status: 1,
      },
      ...params,
    });
  }
}

const adminApi = new AdminApi();

export default adminApi;
